翻訳と辞書
Words near each other
・ "O" Is for Outlaw
・ "O"-Jung.Ban.Hap.
・ "Ode-to-Napoleon" hexachord
・ "Oh Yeah!" Live
・ "Our Contemporary" regional art exhibition (Leningrad, 1975)
・ "P" Is for Peril
・ "Pimpernel" Smith
・ "Polish death camp" controversy
・ "Pro knigi" ("About books")
・ "Prosopa" Greek Television Awards
・ "Pussy Cats" Starring the Walkmen
・ "Q" Is for Quarry
・ "R" Is for Ricochet
・ "R" The King (2016 film)
・ "Rags" Ragland
・ ! (album)
・ ! (disambiguation)
・ !!
・ !!!
・ !!! (album)
・ !!Destroy-Oh-Boy!!
・ !Action Pact!
・ !Arriba! La Pachanga
・ !Hero
・ !Hero (album)
・ !Kung language
・ !Oka Tokat
・ !PAUS3
・ !T.O.O.H.!
・ !Women Art Revolution


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

expression templates : ウィキペディア英語版
expression templates
Expression templates is a C++ template metaprogramming technique in which templates are used to represent part of an expression. Typically, the template itself represents a particular kind of operation, while the parameters represent the operands to which the operation applies.〔
〕 The expression template can then be evaluated at a later time, or passed to a function. The technique was invented independently by Todd Veldhuizen and David Vandevoorde.〔〔
〕〔

For example, consider a library representing vectors with a class Vec. It is natural to want to overload operator- and operator
*
so you could write Vec x = alpha
*(u - v);
where alpha is a scalar and u and v are Vecs. A naive implementation would have operator- and operator
*
return Vecs. However, then the above expression would mean creating a temporary for u-v then another temporary for alpha times that first temporary, then assigning that to x. Even with the return value optimization this will allocate memory at least twice: once for the temporary u-v and once for the result of the overall expression.
Expression templates delay evaluation so the expression Vec x = alpha
*(u-v);
essentially generates at compile time a new Vec constructor. It is as if this constructor takes a scalar and two Vecs by reference; it allocates the necessary memory and then performs the computation. Thus only one memory allocation is performed.
An example implementation of expression templates is as follows (using the curiously recurring template pattern as is used by Boost.uBLAS):

#include
#include
/
* The template parameter is named 'E' for 'Expression'
*/
template
// A CRTP base class for Vecs with a size and indexing:
class VecExpression
value_type operator = v();
}
}
};
template
class VecDifference : public VecExpression >
value_type operator; }
};

template
class VecScaled : public VecExpression >
Vec::value_type operator = v();

to essentially

_data() = alpha
* (u() - v());

with no temporaries needed and only one pass through each memory block.
== Libraries using Expression templates ==

* Boost uBLAS〔
(【引用サイトリンク】 Boost Basic Linear Algebra Library )

* Eigen〔
(【引用サイトリンク】 Eigen: Lazy Evaluation and Aliasing )


抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「expression templates」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.